package com.ssy.lingxi.settle.accounts.model.constant;

import com.ssy.lingxi.common.language.LanguageHolder;
import org.springframework.context.i18n.LocaleContextHolder;

import java.util.Arrays;

/**
 * 平台结算单据类型枚举
 * @author 伍将
 * @date 2020/11/4
 * @version 2.0.0
 */
public enum PlatformSettlementOrderTypeEnum {

    /**
     * 所有单据类型
     */
    ALL(0, "所有单据类型"),
    /**
     * 代收账款结算
     */
    RECEIVE(1, "代收账款结算"),
    /**
     * 积分结算
     */
    SCORE(2, "积分结算"),
    /**
     * 优惠卷
     */
    COUPON(3, "优惠券结算"),
    ;


    private final Integer code;
    private final String message;

    PlatformSettlementOrderTypeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getDeclaringClass(), this.getCode());
    }

    public static String getMessage(Integer code) {
        return Arrays.stream(PlatformSettlementOrderTypeEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(ALL).getMessage();
    }
}
